<?php

class HelpTask extends Task {
    public function __construct($argv) {
        parent::__construct($argv);
        $this->description = "Display the detail description and example of the task.";
        $this->example     = "mini help list";
    }

    public function main() {
        $tasks = $this->argv['input'];

        $helpCount = 0;
        foreach ($tasks as $task) {
            if ($task !== 'help') { // go to the first task in the list that's not help, and display help info on it.
                Task::help(array('task' => $task));
                $helpCount++;
                break;
            }
        }

        if ($helpCount == 0) { // so we didn't help anything
            Task::help(array('taskInstance' => $this));
        }
    }
}